<template>
  <div class="payment">
    <!-- 右侧滑动效果 -->
    <div id="top">
      <b @click="back()">&lt;</b>
      <h3>支付</h3>
    </div>
    <div id="center">
      <div>
        运费金额￥
        <van-field
          class="money"
          readonly
          clickable
          :value="value"
          @touchstart.native.stop="show = true"
        />
      </div>
    </div>
    <div id="bottom">
      <van-number-keyboard
        theme="custom"
        v-model="value"
        :show="show"
        :maxlength="6"
        close-button-text="完成"
        @blur="
          show = false;
          shows = true;
        "
      />
    </div>
    <!-- 弹出层 -->
    <div class="diolag">
      <van-popup
        v-model="shows"
        position="right"
        :style="{ height: '100%', width: '100%' }"
      >
        <div class="diolagtitle">
          <span>&lt;</span>
          <p>支付</p>
          <span></span>
        </div>
        <div class="diolagContent">￥{{ this.value }}</div>
        <div class="diolagBottom">
          <p class="contentTitle">选择第三方支付方式</p>
          <li v-for="item in this.bottomData" :key="item.id">
            <p><img :src="item.imgUrl" alt="" />{{ item.name }}</p>
            <input type="radio" name="aa" />
          </li>
        </div>
        <button class="sure" @click="handSure()">确定</button>
        <!-- 支付 -->
        <div class="pay" v-if="pay">
          <div class="payContent">
            <h3>X 请输入支付密码</h3>
            <div class="payMoney">
              <p class="payContentTitle">支付金额</p>
              <p class="payvalue">￥{{ this.value }}</p>
            </div>
            <button class="payOk" @click="payOk()">确定</button>
            <van-password-input
              :value="values"
              :focused="showKeyboard"
              @focus="showKeyboard = true"
            />
          </div>
          <!-- 数字键盘 -->
          <van-number-keyboard
            v-model="values"
            :show="showKeyboard"
            @blur="showKeyboard = false"
          />
          <!-- 支付成功显示订单 -->
          <van-overlay :show="showw" @click="showw = false">
            <div class="block">
              <div class="paySuccessTitle">
                <span class="paytitleLeft">&lt;</span>
                <p class="paytitle">支付成功</p>
                <span></span>
              </div>
              <!-- 成功的图片 -->
              <div class="successImg"  @click="changeLisr">
                    <dl>
                      <dt><img src="https://static.easyicon.net/preview/120/1201384.gif" alt=""></dt>
                      <dd class="successOK">支付成功</dd>
                    </dl>
              </div>
            </div>
          </van-overlay>
        </div>
      </van-popup>
    </div>
  </div>
</template>

<script>
//输入金额
import Vue from "vue";
import { Overlay } from "vant";

Vue.use(Overlay);
import "vant/lib/overlay/style";
import { NumberKeyboard } from "vant";
import "vant/lib/number-keyboard/style";
Vue.use(NumberKeyboard);
//输入密码
import { PasswordInput } from "vant";
import "vant/lib/password-input/style";
Vue.use(PasswordInput);
export default {
  data() {
    return {
      values: "",
      showKeyboard: true,
      bottomData: [
        {
          id: 1,
          imgUrl:
            "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fbpic.588ku.com%2Felement_origin_min_pic%2F00%2F86%2F90%2F2856ec5a0fc84c0.jpg&refer=http%3A%2F%2Fbpic.588ku.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1619255063&t=5d696d7ab729f38a39f5ce31f8497ce3",
          name: "微信支付",
        },
        {
          id: 2,
          imgUrl:
            "https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1286571192,551066466&fm=26&gp=0.jpg",

          name: "支付宝支付",
        },
        {
          id: 3,
          imgUrl:
            "https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=733739571,2547776000&fm=26&gp=0.jpg",
          name: "银行卡支付",
        },
      ],
      value: "",
      show: true,
      shows: false,
      pay: false,
      showw: false,
    };
  },

  methods: {
    //支付确定按钮
    payOk() {
      this.showw = true;
    },
    //确定按钮
    handSure() {
      this.pay = true;
    },
    // pay() {
    //   console.log("1");
    //   this.$router.push("/pay");
    // },
    onInput() {},
    back() {
      this.$router.go(-1);
    },
    onclick() {},
    changeLisr(){
      this.$router.push('/home')
    }
  },
};
</script>

<style lang="scss" scoped>
.payment {
  width: 100%;
  height: 100%;
}

#top {
  width: 100%;
  height: 4rem;
  background-color: blue;
  b {
    color: white;
    font-size: 1.2rem;
  }
  h3 {
    display: inline-block;
    color: white;
    margin-left: 40%;
    margin-top: 5%;
  }
}
#center {
  width: 100%;
  height: 1rem;
  margin-top: 2rem;
  font-size: 1rem;
  font-weight: bold;
}
.money {
  width: 7rem;
  height: 3rem;
  border: 1px solid #ccc;
  position: fixed;
  top: 6rem;
  left: 6.5rem;
  font-size: 1.1rem;

  line-height: 2rem;
}
.diolag {
  margin-top: 6rem;
  background: #ccc;
  .diolagtitle {
    width: 100%;
    height: 2.6rem;
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    align-items: center;
    background: #4483ec;
    padding: 0 1rem;
    color: #fff;
    font-size: 1.2rem;
  }
  .diolagContent {
    width: 100%;
    height: 12rem;
    text-align: center;
    line-height: 12rem;
    font-size: 2rem;
    color: #ff558a;
    background: #fff;
  }
  .diolagBottom {
    width: 100%;
    height: auto;
  }
  .contentTitle {
    line-height: 2rem;
    font-size: 1rem;
    border-bottom: 0.9px solid #ccc;
    padding: 0 2rem;
    font-weight: bold;
    color: #ccc;
  }
  li {
    width: 100%;
    height: 4rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    border-bottom: 2px solid #ccc;
    font-size: 1rem;
    color: #8f8f8f;
    font-weight: bold;

    img {
      width: 2.2rem;
      height: 2.2rem;
      vertical-align: middle;
      margin: 0 0.6rem;
    }
  }
}
.sure {
  padding: 0.8rem 8rem;
  border: 0;
  outline: none;
  color: #fff;
  background: #4483ec;
  margin: 2.4rem;
}
.pay {
  width: 100%;
  height: 100%;
  background: #898989;
  position: fixed;
  top: 0;
  left: 0;
}
.payContent {
  width: 20rem;
  height: 20rem;
  background: #fff;
  position: fixed;
  top: 4rem;
  left: 2rem;
  h3 {
    width: 100%;
    height: 4rem;
    line-height: 4rem;
    text-align: center;
  }
}
.payMoney {
  width: 100%;
  height: auto;
}
.payContentTitle {
  font-size: 1rem;
  line-height: 2rem;
  text-align: center;
  font-weight: bold;
}
.payvalue {
  font-size: 2rem;
  line-height: 2rem;
  text-align: center;
  font-weight: bold;
  margin: 1rem 0;
}
.payOk {
  padding: 0.3rem 1rem;
  margin: 1rem 7rem;
  background: #148aec;
  color: #fff;
  outline: none;
  border: 0;
}
.wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.block {
  width: 100%;
  height: 100%;
  background-color: #fff;
}
.paySuccessTitle {
  width: 100%;
  height: 2.5rem;
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0.6rem;
  background: #148aec;
  align-items: center;
  color: #fff;
}
.successImg{
    width: 100%;
    height: 30%;
    dl{
      width: 100%;
      height: 100%;
      dt{
        margin-top: 3rem;
      }
      img{
        width: 6rem;
        height: 6rem;
       margin-left: 8.3rem;
      }
    }
    .successOK{
       margin-left: 8.8rem;
         font-weight: bold;
    }
}
</style>
